package ch.selise.archtool.ui.states;

import java.awt.EventQueue;

import javax.swing.JFrame;

import ch.selise.archtool.ui.ArchWindow;
import ch.selise.archtool.ui.Context;
import ch.selise.archtool.ui.FurnitureWindow;

public class FurnitureSelectionState implements State {

	Context context;
	JFrame frame;
	
	public FurnitureSelectionState(Context context)
	{
		this.context = context;
	}
	
	
	
	@Override
	public void process() {
		
		System.out.println("processing " + this.getClass());
		
		
		context.AddFurnitureToHouse(((FurnitureWindow)frame).getSelectedFurnitures());

	}

	@Override
	public void cancel() {
		System.out.println("cancle " +  this.getClass());

	}



	@Override
	public void show() {
		if(frame == null)
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					frame = new FurnitureWindow(context);
					frame.setVisible(true);
					//mainFrame.add(frame);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		else{frame.setVisible(true);}
		
	}

}
